#!/usr/bin/env bash
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
PROJECT_PATH="$(dirname "$CORDOVA_PATH")"

#获取项目相关信息
# XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
# PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)

#获取项目空间相应信息
XCWORKSPACE=$( ls "$PROJECT_PATH" | grep .xcworkspace  )
XCWORKSPACE_NAME=$(basename "$XCWORKSPACE" .xcworkspace)
SCHEME=chameleon-bundled


mkdir "$PROJECT_PATH/archive" || exit$?
"$CORDOVA_PATH/build" --device --release || exit $?
xcrun -sdk iphoneos PackageApplication -v "$PROJECT_PATH/build/device/$XCWORKSPACE_NAME.app" -o "$PROJECT_PATH/archive/$XCWORKSPACE_NAME.ipa"
